// pages/specialList/index.js
var app = getApp();
var rootDocment = app.globalData.postUrl;
Page({

  /**
   * 页面的初始数据
   */
  data: {
    is_member_day: 0,
    is_99_vip: 0,
    goodsList: [],
    is_vip_price: JSON.parse(wx.getStorageSync('is_vip_price') || 'false'),
    userInfo: {}
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    console.log('生命周期函数--监听页面加载', options);
    if (options.type == 'member_day') {
      this.setData({
        is_member_day: 1
      })
    }
    if (options.type == 'vip_99') {
      this.setData({
        is_99_vip: 1
      })
    }
    this.setOrderGoodsData()
  },
  setOrderGoodsData: function () {
    var that = this;
    var paraArr = new Array();
    let type = ''

    if (this.data.is_member_day == 1) {
      type = 'member_day'
    }
    if (this.data.is_99_vip == 1) {
      type = '99_vip'

    }
    paraArr['size'] = "8";
    paraArr['type'] = type;
    paraArr['user_id'] = wx.getStorageSync('user_id3');
    // member_day
    // 99_vip
    var sign = app.signature(paraArr);
    wx.request({
      url: rootDocment + '/api_goods',
      data: {
        size: paraArr['size'],
        type: paraArr['type'],
        user_id: paraArr['user_id'],
        sign: sign
      },
      method: 'GET',
      header: {},
      success: function (res) {
        that.setData({
          goodsList: [...res.data.data]
        });

      }
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    var that = this
    //用户授权登录
    app.login(function (userInfo) {
      that.setData({
        userInfo: userInfo,
        is_vip_price: userInfo.is_vip_price
      });
    });
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})